package oktx.dubbo.participant;

import com.fasterxml.jackson.annotation.JsonIgnore;
import oktx.RemoteType;
import oktx.participant.Participant;

/**
 * Created by huangdachao on 2018/5/15 14:14.
 * 事务中的Dubbo远程调用记录
 */
public class DubboTccParticipant implements Participant {
    private String xid;             // 本次调用分配的事务ID
    private Class<?> clazz;         // dubbo调用对应的接口类
    private String method;          // Dubbo调用对应的接口方法
    private String confirmMethod;   // TCC 确认方法名
    private String cancelMethod;    // TCC 取消方法名
    private String ip;  // 远程服务IP
    private int port;   // 远程服务端口号

    public String getXid() {
        return xid;
    }

    public void setXid(String xid) {
        this.xid = xid;
    }

    public Class<?> getClazz() {
        return clazz;
    }

    public void setClazz(Class<?> clazz) {
        this.clazz = clazz;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getConfirmMethod() {
        return confirmMethod;
    }

    public void setConfirmMethod(String confirmMethod) {
        this.confirmMethod = confirmMethod;
    }

    public String getCancelMethod() {
        return cancelMethod;
    }

    public void setCancelMethod(String cancelMethod) {
        this.cancelMethod = cancelMethod;
    }

    public String getIp() {
        return ip;
    }

    public void setIp(String ip) {
        this.ip = ip;
    }

    public int getPort() {
        return port;
    }

    public void setPort(int port) {
        this.port = port;
    }

    @JsonIgnore
    @Override
    public RemoteType getType() {
        return RemoteType.dubbo;
    }

    @Override
    public String toString() {
        return "DubboParticipant{"
                + "xid='" + xid + '\''
                + ", clazz=" + clazz
                + ", method='" + method + '\''
                + ", confirmMethod='" + confirmMethod + '\''
                + ", cancelMethod='" + cancelMethod + '\''
                + ", ip='" + ip + '\''
                + ", port=" + port
                + '}';
    }
}
